home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / devices / msh_1_5 / part01 / src / hanreq.c < prev    next >
C/C++ Source or Header  |  1990-02-21  |  3KB  |  140 lines

  1. /*-
  2.  * $Id: hanreq.c,v 1.1 89/12/17 20:03:24 Rhialto Exp Locker: Rhialto $
  3.  * $Log:    hanreq.c,v $
  4.  * Revision 1.1  89/12/17  20:03:24  Rhialto
  5.  * Initial revision
  6.  * 
  7.  *
  8.  *  HANREQ.C
  9.  *
  10.  *  The code for the messydos file system handler.
  11.  *
  12.  *  Read/Write error requesters.
  13.  *
  14.  *  This code is (C) Copyright 1989 by Olaf Seibert. All rights reserved. May
  15.  *  not be used or copied without a licence.
  16. -*/
  17.  
  18. #include "dos.h"
  19. #include <exec/io.h>
  20. #include <devices/trackdisk.h>
  21. #include <intuition/intuition.h>
  22.  
  23. #ifdef DEBUG
  24. #   define    debug(x)  dbprintf x
  25. #else
  26. #   define    debug(x)
  27. #endif
  28.  
  29. struct IntuiText Positive = {
  30.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  31.     AUTOLEFTEDGE, AUTOTOPEDGE, AUTOITEXTFONT,
  32.     (UBYTE *)"Retry",
  33.     AUTONEXTTEXT
  34. };
  35.  
  36. struct IntuiText Negative = {
  37.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  38.     AUTOLEFTEDGE, AUTOTOPEDGE, AUTOITEXTFONT,
  39.     (UBYTE *)"Cancel",
  40.     AUTONEXTTEXT
  41. };
  42.  
  43. struct IntuiText RwError[] = {
  44.     {
  45.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  46.     16,          5,       AUTOITEXTFONT,
  47.     (UBYTE *)"Messydos volume",
  48.     &RwError[1]
  49.     },
  50.     {
  51.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  52.     16,          15,       AUTOITEXTFONT,
  53.     (UBYTE *)NULL,
  54.     &RwError[2]
  55.     },
  56.     {
  57.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  58.     16,          25,       AUTOITEXTFONT,
  59.     (UBYTE *)"has a Read or Write error",
  60.     NULL
  61.     },
  62. };
  63.  
  64. struct IntuiText MustReplace[] = {
  65.     {
  66.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  67.     16,          5,       AUTOITEXTFONT,
  68.     (UBYTE *)"You MUST!! replace messy volume",
  69.     &MustReplace[1]
  70.     },
  71.     {
  72.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  73.     16,          15,       AUTOITEXTFONT,
  74.     (UBYTE *)NULL,
  75.     &MustReplace[2]
  76.     },
  77.     {
  78.     AUTOFRONTPEN, AUTOBACKPEN, AUTODRAWMODE,
  79.     16,          25,       AUTOITEXTFONT,
  80.     (UBYTE *)"in that floppy drive !!",
  81.     NULL
  82.     },
  83. };
  84.  
  85. long AutoRequest();
  86. extern struct DosPacket *DosPacket;
  87. extern struct DeviceList *VolNode;
  88. extern short DiskChanged;
  89.  
  90. long
  91. RetryRwError(req)
  92. struct IOExtTD *req;
  93. {
  94.     register struct Window *window;
  95.     struct MsgPort *port;
  96.     struct Process *proc;
  97.     struct IntuiText *text;
  98.     long result;
  99.  
  100.     if (DosPacket != NULL) { /* A user-requested action */
  101.     port = DosPacket->dp_Port;
  102.     if ((port->mp_Flags & PF_ACTION) != PA_SIGNAL)
  103.         goto fail;
  104.     proc = (struct Process *)port->mp_SigTask;
  105.     if (proc->pr_Task.tc_Node.ln_Type != NT_PROCESS)
  106.         goto fail;
  107.     window = (struct Window *)proc->pr_WindowPtr;
  108.     if (window == (struct Window *)-1)
  109.         goto fail;
  110.     } else
  111.     window = NULL;
  112.  
  113.     if (req->iotd_Req.io_Error == TDERR_DiskChanged) {
  114.     text = MustReplace;
  115.     DiskChanged = 0;
  116.     } else
  117.     text = RwError;
  118.  
  119.     if (VolNode)
  120.     text[1].IText = (UBYTE *)BTOC(VolNode->dl_Name)+1;
  121.     else
  122.     text[1].IText = NULL;
  123.  
  124. again:
  125.     result = AutoRequest(window, text, &Positive, &Negative,
  126.                0L, 0L, 320L, 72L);
  127.  
  128.     if (req->iotd_Req.io_Error == TDERR_DiskChanged && result != FALSE) {
  129.     if (DiskChanged == 0)   /* Cheating, huh ? */
  130.         goto again;
  131.     TDChangeNum();  /* Get new disk change number */
  132.     DiskChanged = 0;
  133.     }
  134.  
  135.     return result;
  136.  
  137. fail:
  138.     return FALSE;
  139. }
  140.